<?php
 /**
 * Example Application
 * @package Example-application
 */
exit;
error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_WARNING));
require('../lib/smarty/Smarty.class.php');
require('../lib/functions.php');
require('../lib/mySQL.php');
require('../lib/public_page_class.php');
require('../lib/upload.class.php');
require('../configs/config.php');
require("../lib/json.php");
header("Content-type: text/html; charset=utf-8");
session_start();
$CONF['page_size'] = 15;                  //每页多少条记录
$CONF['upload_path'] = "../img/";         //图片保存路径
$CONF['upload_maxSize'] = "1024"; //1m;   //上传图片大小限制
$CONF['ad_url'] = ""; //推广链接地址前缀
$CONF['dbkey'] = "ep[ds@1;~32128z";
$gWeb = new Web();
$INCOME = $gWeb->parse_incoming();
$gAct = $INCOME['act'];
if(empty($_SESSION['adminUser']) || empty($gAct))
{
	$gAct = "login";
}
else if($_SESSION['adminUser'] && empty($gAct))
{
	$gAct = "main";
}

$gOp = $INCOME['op'];
//$smarty->force_compile = true;
$gSmarty = new Smarty;
$gSmarty->debugging = false;
$gSmarty->caching = false;
$gSmarty->cache_lifetime = 120;
$gPageName=basename($_SERVER['PHP_SELF'],"/");
$DB = new DB;
$DB->info['host'] = $CONF['db_host'];
$DB->info['usr']  = $CONF['db_user'];
$DB->info['pwd']  = $CONF['db_pass'];
$DB->info['db']   = $CONF['db_db'];
$DB->db_connect();
mysql_query("set names utf8");
$d = file("ft.txt");
$countInsert = 0;
$eeee = 0;
echo count($d);
foreach($d as $x)
{
	$d= explode(",",trim($x));
$f['roleId'] = 3;
$f['roleName'] = "下载";
$f['addTime'] = date("Y-m-d H:i:s");
$f['validDate'] = "2017-01-31";
	 
	if($d[2])
	{
		$f['realName'] = trim($d[0]);
		$f['com'] = trim($d[1]);
		$f['email'] = trim($d[2]);
		//$f['address'] = trim($d[3]);
		$d2 = explode("@",trim($d[2]));
		$f['name'] = trim($d2[0]);
		$f['pass'] = md5(trim($f['name']));

		$r = $DB->db_query_first("select * from admin_info where email='".$f['email']."'");
		if(empty($r))
		{
			$DB->db_form_insert("admin_info",$f,true);
			echo "<font color='red'>".$f['email']."</font><br/>";
			$countInsert++;
		}
		else {
			$eeee++;
			$DB->db_form_update("admin_info",$f,"id=".$r['id'],true);
			echo $r['name']."===".$r['email']."===".$f['email']."<br/>";
		}
	}
	unset($f);
}
echo $countInsert;
?>
